package com.generalsentiment.evaluation

import scala.collection.mutable.HashSet
import scala.collection.JavaConversions._
import java.io.File
import java.io.IOException

class SentimentAnswerSet(private val baseLocation: String) {
  val answers = new HashSet[SentimentTest]()

  // find all subdirectories in the passed in base dir and intialize a new test suite for them
  val baseDir = new File(baseLocation)
  baseDir.listFiles.map(SentimentTest(_)).foreach(potentialElement => potentialElement match {
    case Some(x) => answers.add(x)
    case None => ()
  })
 
  // create a new set of queries to run for this set of answers
  def makeQueries( outputBase: String ): Unit = {
    val destination = new File(outputBase)
    if(destination.exists()) {
      answers.foreach(_.makeQueries(destination))
    } else {
      throw new IOException("Output directory does not exits!");
    }
  }
}
